package com.system.server;

import java.net.ServerSocket;
import java.net.Socket;

public class Server {

    private static final int PORT=8888;

    public static void main(String[] args) throws Exception{

        ServerSocket serverSocket=null;
        Socket socket=null;

        try{
            serverSocket=new ServerSocket(PORT);
            UIThread uiThread=new UIThread();
            uiThread.start();
            while(true){
                try{
                    socket = serverSocket.accept();
                    ServerThread serverThread=new ServerThread(socket);
                    serverThread.start();

                }catch (Exception e){
                    System.out.println("客户端与服务端连接异常");
                    e.printStackTrace();
                }
            }
        }catch (Exception e){
            System.out.println("端口被占用");
            e.printStackTrace();
        }finally {
            serverSocket.close();
        }
    }
}
